/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package times.persistence.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrator
 */
@Entity
@Table(name = "animal_species")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AnimalSpecies.findAll", query = "SELECT a FROM AnimalSpecies a"),
    @NamedQuery(name = "AnimalSpecies.findById", query = "SELECT a FROM AnimalSpecies a WHERE a.id = :id"),
    @NamedQuery(name = "AnimalSpecies.findByAnimalName", query = "SELECT a FROM AnimalSpecies a WHERE a.animalName = :animalName")})
public class AnimalSpecies implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "animal_name")
    private String animalName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "animalSpeciesId")
    private List<Category> categoryList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "animalSpeciesId")
    private List<PriceSource> priceSourceList;

    public AnimalSpecies() {
    }

    public AnimalSpecies(Integer id) {
        this.id = id;
    }

    public AnimalSpecies(Integer id, String animalName) {
        this.id = id;
        this.animalName = animalName;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAnimalName() {
        return animalName;
    }

    public void setAnimalName(String animalName) {
        this.animalName = animalName;
    }

    @XmlTransient
    public List<Category> getCategoryList() {
        return categoryList;
    }

    public void setCategoryList(List<Category> categoryList) {
        this.categoryList = categoryList;
    }

    @XmlTransient
    public List<PriceSource> getPriceSourceList() {
        return priceSourceList;
    }

    public void setPriceSourceList(List<PriceSource> priceSourceList) {
        this.priceSourceList = priceSourceList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AnimalSpecies)) {
            return false;
        }
        AnimalSpecies other = (AnimalSpecies) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return animalName;
    }
    
}
